<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%--
  Created by IntelliJ IDEA.
  User: 黑黑侠
  Date: 2019/11/5
  Time: 22:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>教师选课页面</title>
    <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
    <link href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <style type="text/css">
        *{
            margin:0;
            padding:0;
        }
        .div{
            margin-top:30px;
            width:100%;
            font-size:20px;
            text-align:center;
        }
        .title{
            width: 100%;
            height: 50px;
            line-height: 80px;
            /*text-align: center;*/
            font-size: 30px;
            font-family: kaiti;
        }
    </style>
</head>
<body>

<div style="width:705px;height: 700px; margin: 0 auto">

    <div class="title">
        <button onclick="goReturn()" class="btn btn-warning"style="font-size: 20px;">⬅</button>
        <b style="margin-left: 200px">选课结果</b>
        <a hidden>${teacher.tea_name}</a>
        <a hidden>${teacher.gettea_account()}</a>
    </div>
    <div>
        <div class="div">
            <table class="table table-striped">
                <thead style="background-color: #87CEFA;opacity: 0.9">
                <tr>
                    <th>ID</th><th>课序号</th><th>课程名称</th><th>上课时间</th><th>学分</th><th>课时</th><th>必修/选修</th><th>课容量</th><th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach var="lists" items="${list}" >
                    <tr>
                        <td>${lists.id}</td>
                        <td id="no">${lists.course_no}</td>
                        <td id="name">${lists.course_name}</td>
                        <td>${lists.course_start}~${lists.course_end}</td>
                        <td>${lists.course_socer}</td>
                        <td>${lists.course_hour}</td>
                        <td>${lists.course_attribute}</td>
                        <td>${lists.course_volume}</td>
                        <td><button onclick="deletebyid(this)" class="btn btn-danger">删除</button></td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    function deletebyid(e) {
        var no = $(e).parent().parent().children("#no").text();
        var name = $(e).parent().parent().children("#name").text();
        //$(e)是接收到的button.要想取到td里面的值要先去parent父级parent父级到tr处
        //然后再到children找到<td>,在"[id]",是查找所有含有id的元素,然后.text()是获取值
        //alert(id);
        var re = window.confirm("确定要删除"+name+"课吗?");
        if(re){
             window.location.href="deletebyid?no="+no;
        }
    }
    function goReturn() {
        window.history.go(-1);
    }
    <%--window.onload=function(){--%>
    <%--    var msg = ${msg};--%>
    <%--    if(msg==1){--%>
    <%--        alert("删除成功");--%>
    <%--    }--%>
    <%--}--%>
</script>
</html>
